#include "Follows.h"
#include <iostream>
#include <vector>

using namespace std;

typedef int INTEGER;
typedef int INDEX;
typedef string STRING;
typedef int LINENUM;

	
	Follows::Follows(){
		_size= 0;
		_table = vector<pair<LINENUM,LINENUM>>();
	}
    BOOLEAN Follows::setFollows(LINENUM line1, LINENUM line2){
		pair<LINENUM,LINENUM> p = pair<LINENUM,LINENUM>(line1,line2);
		_table.push_back(p);
		_size++;
		return true;
	}
	vector<pair<LINENUM,LINENUM>> Follows::getFollowsPair(){
		return _table;
	}
	LINENUM Follows::getFollowsSize(){
		return _size;
	}
	LINENUM Follows::getFollowee(LINENUM num2){
		for(int i=0;i<_size;i++){
			if(_table.at(i).second==num2){
				return _table.at(i).first;
			}
		}
		return -1;
	}
    LINENUM Follows::getFollower(LINENUM num1){
		for(int i=0;i<_size;i++){
			if(_table.at(i).first==num1){
				return _table.at(i).second;
			}
		}
		return -1;
	}
	BOOLEAN Follows::isFollows(LINENUM num1,LINENUM num2){
		LINENUM tempNum = getFollower(num1);
		return tempNum == num2;
	}
	BOOLEAN Follows::isFollowsStar(LINENUM num1,LINENUM num2){
		if(isFollows(num1,num2))
			return true;
		else if(getFollower(num1)== -1)
			return false;
		else 
			return isFollowsStar(getFollower(num1),num2);
	}












	   